import React from "react";
import Helmet from "react-helmet";
import { graphql } from "gatsby";
import Layout from "../layout";
import PostListing from "../components/PostListing";
import SEO from "../components/SEO";
import config from "../../data/SiteConfig";

class Index extends React.Component {
  render() {
    const postEdges = this.props.data.allStrapiArticle.edges;
    return (
      <Layout location={this.props.location} title="首页">
        <div className="index-container">
          <Helmet>
            <title>{config.siteTitle}</title>
            <link rel="canonical" href={`${config.siteUrl}`} />
          </Helmet>
          <SEO postEdges={postEdges} />
          <PostListing postEdges={postEdges} />
        </div>
      </Layout>
    );
  }
}

export default Index;

export const pageQuery = graphql`
 query IndexQuery {
    allStrapiArticle(
      limit:2000,
      sort: {fields: [top,createdAt], order: ASC}
      
    ) {
      edges {
        node {
          id
          top
          title
          content
          createdAt
          cover{id name publicURL}
          tags{id name}
        }
      }
    }
  }
`;
